﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using QLNS_v1.Bus;


namespace QLNS_v1.Form
{
    public partial class FrmOption : DevExpress.XtraEditors.XtraForm
    {
        LuongCB_Bus lcbb = new LuongCB_Bus();
        OptionBH_Bus opbhb = new OptionBH_Bus();
        Option opl = new Option();
        OptionBH opbh = new OptionBH();

        long idl = 0;
        long idbh = 0;
        public FrmOption()
        {
            InitializeComponent();
            List<Option> list = lcbb.ListLuongCB();
            List<OptionBH> listbh = opbhb.ListBH();
            foreach (var a in list)
            {
                idl = a.OptionID;
                txtLCB.Text = a.LuongCoBan.ToString();
                dateNgay.EditValue = DateTime.Parse(a.Ngay.ToString());
            }
            foreach (var a in listbh)
            {
                idbh = a.id;
                txtBHXH1.Text = a.BHXH.ToString();
                txtbhyt.Text = a.BHYT.ToString();
                txtbhtn.Text = a.BHTN.ToString();
            }
        }
        private void getvalues()
        {
            opl.OptionID = idl;
            opl.LuongCoBan = double.Parse(txtLCB.Text);
            opl.Ngay = DateTime.Parse(dateNgay.EditValue.ToString());
            opbh.id =int.Parse( idbh.ToString());
            opbh.BHTN = double.Parse(txtbhtn.Text);
            opbh.BHXH = double.Parse(txtBHXH1.Text);
            opbh.BHYT = double.Parse(txtbhyt.Text);
            opbhb.Update(opbh);
            lcbb.Update(opl);
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            getvalues();
            this.Close();
        }

    }
}